package org.jeecg.codegeneweb.util;

import java.io.BufferedWriter;
import java.io.File;
import java.io.FileWriter;
import java.io.IOException;

public class FileSaveExample {
    public static void main(String[] args) {
        String content = "这是一个示例文本内容。";
        String filePath = "d:\\xy\\zz\\example.txt";
        File filedirpath=new File("d:\\xy\\zz\\");
        if(!filedirpath.exists()) {//如果文件夹不存在则创建
            filedirpath.mkdirs();
        }
        // 创建文件并写入内容
        try (BufferedWriter writer = new BufferedWriter(new FileWriter(filePath))) {
            writer.write(content);
            System.out.println("文件保存成功！");
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}
